package com.mjf.common.utils;

/**
 * @author chenshoumeng
 */

public enum ResponseCode {

    /** 操作成功 */
    RESPONSE_RETURN_CODE_SUCCESS(200, "操作成功"),
    RESPONSE_CODE_SYSTEM_ERROR(500, "操作失败"),
    RESPONSE_CODE_SYSTEM_INV(401, "登录失效"),
    RESPONSE_CODE_CAPTCHA_NOT_NULL(500, "验证码不能为空"),
    RESPONSE_CODE_CAPTCHA_ERROR(500, "验证码错误"),
    USERNAME_OR_PASSWORD_ERROR(500, "用户名或密码错误"),
    USERNAME_EXIST(500, "用户名已存在"),
    USER_NOT_EXIST(500, "用户不存在"),
    ;

    // status code
    private Integer code;
    // response msg
    private String message;

    ResponseCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ResponseCode getResponseByCode(String code) {
        for (ResponseCode eCode : ResponseCode.values()) {
            if (eCode.getCode().equals(code)) {
                return eCode;
            }
        }
        return null;
    }

}
